import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import strip from "@rollup/plugin-strip";
import typescript from "@rollup/plugin-typescript";
// import autoprefixer from "autoprefixer";
// import path from "path";
import json from '@rollup/plugin-json';
import externals from "rollup-plugin-node-externals";
// import postcss from "rollup-plugin-postcss";

export default {
  input: "src/index.ts", // 入口文件
  output: [
    {
      dir: './dist/esm',
      format: "es",
      name: 'yhy-utils',
      exports: "named", // 指定导出模式（自动、默认、命名、无）
      preserveModules: true, // 保留模块结构
      preserveModulesRoot: "src", // 将保留的模块放在根级别的此路径下
    }
  ],
  plugins: [
    // 自动将dependencies依赖声明为 externals
    externals({ devDeps: false }),
    json(),
    // 处理外部依赖
    resolve(),
    // 支持基于 CommonJS 模块引入
    commonjs(),
    // 支持 typescript，并导出声明文件
    typescript({ outDir: './dist/esm/types', declaration: true, declarationDir: './dist/esm/types', }),
    // 支持 scss，并添加前缀
    // postcss({ plugins: [autoprefixer()], }),
    // 清除调试代码
    strip()
  ]
};
